﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cache.Contract
{
    public interface ICache
    {

        /// <summary>
        /// 增加对象到缓存
        /// </summary>
        /// <typeparam name="T">可以序列化的对象</typeparam>
        /// <param name="key">Key</param>
        /// <param name="obj">对象</param>
        /// <returns>bool</returns>
        bool Add<T>(string key, T obj);
        /// <summary>
        /// 增加对象到缓存
        /// </summary>
        /// <typeparam name="T">可以序列化的对象</typeparam>
        /// <param name="key">Key</param>
        /// <param name="obj">对象</param>
        /// <param name="t">超时时间</param>
        /// <returns>bool</returns>
        bool Add<T>(string key,T obj,TimeSpan t);

        /// <summary>
        /// 取得缓存中的对象
        /// </summary>
        /// <typeparam name="T">可以序列化的对象</typeparam>
        /// <param name="key">Key</param>
        /// <returns>T</returns>
        T Get<T>(string key);

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="key">Key</param>
        /// <returns>bool</returns>
        bool Remove(string key);

        /// <summary>
        /// 清空所有缓存
        /// </summary>
        void ClearAll();

    }
}
